package be.ipl.eBar.daoimpl;

import java.util.List;

import javax.ejb.Stateless;

import be.ipl.eBar.dao.BiereDao;
import be.ipl.eBar.domaine.Biere;

@SuppressWarnings("serial")
@Stateless
public class BiereDaoImpl extends DaoImpl<Biere> implements BiereDao {
	@Override
	public List<Biere> lister(String mot) {
		mot = mot.toLowerCase();
		String queryString = "select b from Biere b " + 
					"where lower(b.nom) like ?1 " + 
					"or lower(b.type) like ?1 " + 
					"or lower(b.couleur) like ?1 " + 
					"or lower(b.brasserie.nom) like ?1 "; 

		return liste(queryString, mot);
	}

	@Override
	public Biere rechercher(String nom) {
		String queryString = "select b from Biere b where b.nom = ?1";
		return recherche(queryString, nom);
	}

	@Override
	public Biere chargerFournisseurs(Biere biere) {
		biere = super.recharger(biere.getId());
		biere.getFournisseurs().size();
		return biere;
	}
}
